#include "framework.hh"

bool Framework::onInstall(kconfig::Config*) {
    return true;
}

bool Framework::onUninstall() {
    return true;
}

bool Framework::onStart(kconfig::Config*) {
    return true;
}

bool Framework::onStop() {
    return true;
}

ModuleType Framework::onModuleType() {
    return ModuleType::EVENT_MODULE;
}

std::string Framework::onCommand(const std::string&) {
    return std::string();
}

void Framework::onTick(std::time_t) {
}

void Framework::onPathJoin(PathID, SiteType, UserData) {
}

void Framework::onPathDisjoin(PathID, SiteType) {
}

void Framework::onFindPathTimeout(SiteType, UserData) {
}

void Framework::onPathData(PathID pathID, SiteType siteType, std::uint32_t msgID, Message & msg) {
    auto handler = ProtocolRegisterRef.getHandler(msgID);
    if (handler) {
        handler->onPathMessage(pathID, siteType, msg);
    } else {
        errorlog << "Message ID not found, PATH MSGID:" << msgID << endlog;
    }
}

void Framework::onPathData(PathID, SiteType, std::uint32_t msgID,
    const char*, std::size_t) {
    errorlog << "Message ID not found, PATH MSGID:" << msgID << endlog;
}

void Framework::onSessionJoin(SessionID) {
}

void Framework::onSessionDisjoin(SessionID) {
}

void Framework::onSessionData(SessionID sessionID, std::uint32_t msgID, Message & msg) {
    auto handler = ProtocolRegisterRef.getHandler(msgID);
    if (handler) {
        handler->onSessionMessage(sessionID, msg);
    } else {
        errorlog << "Message ID not found, SESSION MSGID:" << msgID << endlog;
    }
}

void Framework::onSessionData(SessionID, std::uint32_t msgID, const char*, std::size_t) {
    errorlog << "Message ID not found, SESSION MSGID:" << msgID << endlog;
}

void Framework::onTimer(TimerHandle, std::uint64_t) {
}

void Framework::onSiteJoin(const kratos::grid::SiteID&) {
}

void Framework::onSiteDisjoin(const kratos::grid::SiteID&) {
}

void Framework::onSiteData(const kratos::grid::SiteID & siteID, std::uint32_t msgID, Message&) {
    errorlog << "Message ID not found, SITE ID:" << siteID.toString() << ", MSGID:" << msgID << endlog;
}

void Framework::onSiteData(const kratos::grid::SiteID & siteID, std::uint32_t msgID, const char*, std::size_t) {
    errorlog << "Message ID not found, SITE ID:" << siteID.toString() << ", MSGID:" << msgID << endlog;
}

void Framework::onEntityFound(std::uint32_t, const EntityIDVector&, std::uint64_t) {
}

void Framework::onHttpData(SessionID, const kratos::util::HttpProto&) {
}

void Framework::onSessionConnected(SessionID, std::uint64_t) {
}
